#!/bin/sh

if [ ! -f "/usr/bin/docker" ]; then
    distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
    curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
    curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
    sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit nvidia-docker2
    echo "install docker finish ."

    # 把当前用户加入到 docker 组；
    sudo gpasswd -a $USER docker
    # 更新docker组
    newgrp docker
    # 增加自动启动
    sudo systemctl enable docker
    sudo systemctl restart docker
    echo "add docker user finish ."
fi



if [ ! -f "/usr/local/bin/docker-compose" ]; then
    sudo curl -L "https://github.com/docker/compose/releases/download/v2.28.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sudo chmod 755 /usr/local/bin/docker-compose
    echo "install docker-compose finish ."
fi




